All right, so today I'm going to introduce variables.
So I have my first game right here.
I have my part right here.
And then I have this printed script for my last video.
I'm going to select that and turn this off.
I'm going to disable it.
So as disabled, click it and now it's disabled, it won't run.
You see how gray it is.
Let's go ahead and add another script.
Click my part, plus sign script.
And this one is going to be variables.
I spelled the wrong variables.
There we go.
And now let me read off the computer science definition of variable so that it's formal variables are
used to label and store data in memory so your program can use it.
Let's just go ahead and see how it's done because you don't really need to know the definition in order
how to in order to know how to use it.
So I just got rid of that print statement.
We don't need it.
And now we're going to declare a variable.
That's what it's called.
When you add a variable to your program, you're declaring it.
I'm going to say local file equals five, right?
So local is a scope modifier.
It says, where can I use this variable?
We're going to be local, local to this script in this case.
And then this is the name of the variable I decided to call it.
Now you can call it what you want, but it should make sense.
And then we're going to assign five, so we're going to give it the number five.
So from here on out right now that Val is worth five.
All right, let's do another let's do another variable.
Local will say word.
We're going to do a string data type.
This is a number data type.
Let's do a string.
We kind of know what strings are.
We need these speech quotes and then we'll do characters inside.
Yea that's a string and it's also a word which is very descriptive for our variable.
All right, let's do something else.
I'm going to do a Boolean data type.
Boolean means it could be true or false, right?
That's it.
True or false?
It's a guy.
A guy named George Boole came up with this type of logic.
So it doesn't mean like to in Spanish or anything, it just means his name.
So we'll say Can Touch is going to be a boolean data type.
So it could be true or false?
True.
There we go.
Maybe like a a coin or something.
And you can touch it at a certain point of time and it'll be true and then we'll use that.
Fi All right, let's print these values out.
Print these variables out, I should say.
So we have the value of VAO.
We know how to do that from the last video.
We also know that you can comma to limit stuff in the print statement and that will print out.
Also, we can just put the name of the variable Val and it'll print out a five there.
Print will say the word of the day equals say a word.
And then let's do one for can touch.
Can touch is enabled.
Guys pretty cool.
You actually don't have to put that space there.
Roblox is pretty friendly and will add spacing in between whatever is common, too limited for readability
so we can say can touch sweet.
Let's go ahead and print this out.
So it's a play.
There we go.
The value of value is five.
The word of the day is eight.
Can touch, is enabled, is true.
Cool.
All right.
Now, because this is called a variable, you might suspect there's some sort of flexibility in it.
And you can change it.
You can.
You would be right.
Let's go ahead and get rid of this so we have more room.
There we go.
All right.
Let's go ahead and change.
Vow to ten.
Notice I didn't need local because it's already been declared.
We're just reassigning ten to the variable valve.
Now word.
Let's get something else something cool that young people say, I don't know cap.
Right.
They say stuff like that and now I'll say can touch the only thing it could be is false or true.
Right?
So it was true.
We can make a false or we could be tricky.
We could say not can touch, right?
If can only be two things.
If you put not in front of it, it'll be the other thing.
So now that'll be false.
Let's print stuff out.
I'm just going to copy this.
I'm going to highlight all that right click copy or control C come down here, right click paste.
Cool.
All right, now I have two listings.
One of the old values, one of the new values or one of the first values.
One with the second values.
We can't see it.
We need our output window view output.
Cool.
There's a lot there.
There we go.
Just pull that up.
Says the value of vows five or the days you eat and then enabled can't touch as enabled is true.
And then we changed our stuff.
So now we have our ten, we have our cap.
Look at that.
False.
So when we said not can touch and it was true, it flipped it to false.
And yes, you could do not not and that would and that would change it back the true.
But you don't want to have anything too tricky in your code.
All right.
So that will do it for today.
Just a basic introduction of variables.
Next video.
We are going to get parts like my part and we're going to start working with the properties.
We're going to assign that to a variable and some of the part properties, the variables.
That's going to be fun.
I will see you in the next video.